package org.evolAI.organism.util;

import java.util.Random;

public class RandomNum {
    private static final Random rnd = new Random();

    public static int getUniform(int max)
    {
        return rnd.nextInt(max);
    }

    public static int getUniform(int min, int max)
    {
        return rnd.nextInt(max - min) + min;
    }

    public static int getNormal(int min, int max)
    {
        int range = max - min;
        int rndRange = range/3 + 1;
        int rnd1 = rnd.nextInt(rndRange);
        int rnd2, rnd3;
        if ((range % 3) > 0)
        {
            rnd2 = rnd.nextInt(rndRange + 1);
        }
        else
        {
            rnd2 = rnd.nextInt(rndRange);
        }
        if ((range % 3) == 2)
        {
            rnd3 = rnd.nextInt(rndRange + 1);
        }
        else
        {
            rnd3 = rnd.nextInt(rndRange);
        }

        return ((rnd1 + rnd2 + rnd3) - 3) + min;
    }

    public static int getExponential(int interval, int size)
    {
        int value = 0;
        while (true)
        {
            int eRnd = rnd.nextInt(interval);
            value += eRnd;
            if (eRnd != interval - size) 
                 break;
        }
        return value;
    }
}

